<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../common/admin.asp"-->
<%
id=request.QueryString("id")
if id<>"" then
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from [key] where id="&id&""
	rs.open sql,conn,1,3
	if not rs.eof then
		 title=rs("title")
		 jptitle=rs("jptitle")
		 typeid=rs("typeid")
	rs.close
	set rs=nothing
	end if
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>add</title>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
</head>

<body>
<div class="main">
  <div class="main-title">编辑</div>
  <div class="main-content">
  <%if id="" then%>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <form action="" method="post">
  <tr>
    <td width="29%" bgcolor="#FFFFFF">中文名称</td>
    <td width="71%" bgcolor="#FFFFFF"><input name="title" type="text" class="input" id="title" /></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">日文名称</td>
    <td bgcolor="#FFFFFF"><input name="jptitle" type="text" class="input" id="jptitle" /></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">类型</td>
    <td bgcolor="#FFFFFF"><select name="typeid" id="typeid">
      <option value="0">竞拍</option>
      <option value="1">代购</option>
    </select></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF"><input type="submit" name="button" id="button" value="添加" /> <a href="javascript:;" onClick="javascript:history.back(-1);">取消</a>
      </td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    </form>
  </table>
  <%else%>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <form action="" method="post">
  <tr>
    <td width="29%" bgcolor="#FFFFFF">名称</td>
    <td width="71%" bgcolor="#FFFFFF"><input name="jptitle" type="text" class="input" id="jptitle" value="<%=jptitle%>" />
      （<%=title%>）</td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">类型</td>
    <td bgcolor="#FFFFFF"><select name="typeid" id="typeid">
      <option value="0" <%if typeid="0" then response.Write " selected"%>>竞拍</option>
      <option value="1" <%if typeid="1" then response.Write " selected"%>>代购</option>
    </select></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF"><input type="submit" name="button" id="button" value="保存" /> <a href="javascript:;" onClick="javascript:history.back(-1);">取消</a>
      </td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    </form>
  </table>
  <%end if%>
</div>
</div>
</body>
</html>
<%
if request.Form("button")="保存" then

	  jptitle=request.Form("jptitle")
	  typeid=request.Form("typeid")

	  if jptitle="" or typeid="" then
	  response.write"<script>alert('关键字不能为空');</script>"
	  response.write"<script>window.history.back(-1);</script>"
	  response.end
	  end if
	  
	  set rsx=server.createobject("adodb.recordset")
	  sql="select * from [key] where id="&id&""
	  rsx.open sql,conn,1,3
	  rsx("jptitle")=jptitle
	  rsx("typeid")=typeid
	  rsx.update
	  response.write"<script language=JavaScript>{window.alert('保存成功！');window.location.href='add.asp?id="&id&"';}</script>"
	  rsx.close
	  set rsx=nothing

elseif request.Form("button")="添加" then

	  title=request.Form("title")
	  jptitle=request.Form("jptitle")
	  typeid=request.Form("typeid")

	  if title="" or jptitle="" or typeid="" then
	  response.write"<script>alert('名称，日文名称不能为空');</script>"
	  response.write"<script>window.history.back(-1);</script>"
	  response.end
	  end if
	  
	  set rsx=server.createobject("adodb.recordset")
	  sql="select * from [key]"
	  rsx.open sql,conn,1,3
	  rsx.addnew
	  rsx("title")=title
	  rsx("jptitle")=jptitle
	  rsx("typeid")=typeid
	  rsx.update
	  response.write"<script language=JavaScript>{window.alert('添加成功！');window.location.href='view.asp';}</script>"
	  rsx.close
	  set rsx=nothing
end if
%>